﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class XSPFPlaylist : LastfmModelBase
    {
        public XSPFPlaylist()
        {
            this.Version = string.Empty;
            this.Title = string.Empty;
            this.Annotation = string.Empty;
            this.Creator = string.Empty;
            this.Date = DateTime.MinValue;
            this.TrackList = new List<XSPFPlaylistTrack>();
        }

        public XSPFPlaylist(XmlNode xSPFPlaylistNode)
            : this()
        {
            if (xSPFPlaylistNode == null) return;
            this.InitializeFromXmlNode(xSPFPlaylistNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.Version = node.GetAttributeValue("version");
            this.Title = node.GetChildValue("title");
            this.Annotation = node.GetChildValue("annotation");
            this.Creator = node.GetChildValue("creator");
            this.Date = node.GetChildValue("date").ToDateTime();
            this.TrackList = LastfmModelBase.GetList<XSPFPlaylistTrack>(node.GetChild("trackList"));
        }

        public string Version
        {
            get;
            set;
        }

        public string Title
        {
            get;
            set;
        }

        public string Annotation
        {
            get;
            set;
        }

        public string Creator
        {
            get;
            set;
        }

        public DateTime Date
        {
            get;
            set;
        }

        public IList<XSPFPlaylistTrack> TrackList
        {
            get;
            set;
        }
    }
}
